// import React, { Component } from 'react'

// export default class App extends Component {
//   state = {
//     file: ''
//   }
//   componentDidMount() {
//     document.getElementById('file').addEventListener('change', (e)=> {
//       console.log(e.target.files)
//     })
//   }
//   render() {
//     return (
//       <div>
//         <input type="file" id='file' />
//       </div>
//     )
//   }
// }

import React, { Component } from 'react'

export default class App extends Component {
  constructor(props){
    super(props)
    this.ref = React.createRef()
  }
  state = {
    file: ''
  }
  handleGetRefDom = ()=> {
    console.log(this.ref.current)
  }
  render() {
    return (
      <div>
        <input type="file" ref={this.ref}/>
        <button onClick={this.handleGetRefDom}>获取fileDom元素</button>
      </div>
    )
  }
}

